<?php
class SessionManager {
   public function __construct() {
      session_start();
   }
   public function getUser() {
      if(isset($_SESSION[self::$CURR_USER])) {
         return $_SESSION[self::$CURR_USER];
      }
      else {
         return null;
      }
   }

   public function setUser($user) {
      if($user != null) {
         $_SESSION[self::$CURR_USER] = $user;
      }
      else {
         clearUser();
      }
   }

   public function clearUser() {
      if(isset($_SESSION[self::$CURR_USER])) {
         session_unregister(self::$CURR_USER);
      }
   }

   public function destory() {
      session_destroy();
   }

   public static $CURR_USER = "CURRENT_USER";
}
?>